package com.ibeeking.found.common.config.feign.fallback;

import com.ibeeking.found.common.config.feign.CsUserClient;
import com.ibeeking.found.common.entity.UserInfoDTO;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class CsUserFallbackFactory implements FallbackFactory<CsUserClient> {
    @Override
    public CsUserClient create(Throwable throwable) {
        return new CsUserClient() {
            @Override
            public ResponseResult<UserInfoDTO> queryLoginUser(Long userId) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查看登录用户信息失败。" + throwable.getMessage());
            }
        };
    }
}
